package com.qzsoft.zhjd.asphalt.modules.producemonitor.controller;

import java.util.Map;

import com.qzsoft.zhjd.asphalt.modules.producemonitor.dto.ProduceMonitorChartDto;
import com.qzsoft.zhjd.asphalt.modules.producemonitor.dto.ProduceMonitorDayChartDto;
import com.qzsoft.zhjd.asphalt.modules.producemonitor.service.AsphaltProduceMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;

/**
 * @ClassName AsphaltProduceMonitorController
 * @Description 沥青生产监控控制器
 * @author linhuawei
 * @since 2022-01-29
 */
@RestController
@RequestMapping("/api/asphaltProduceMonitor")
public class AsphaltProduceMonitorController {

    @Autowired
    private AsphaltProduceMonitorService asphaltProduceMonitorService;

    /**
     * @Title getChartData
     * @Description 获取级配曲线图表数据
     * @param id 数据主键
     * @return 级配曲线图表数据
     */
    @GetMapping("/getChartData/{id}")
    public Result<ProduceMonitorChartDto> getChartData(@PathVariable("id") String id) {
        ProduceMonitorChartDto data = asphaltProduceMonitorService.getChartData(id);
        return ResultUtils.ok(data);
    }

    /**
     * @Title getDayChartData
     * @Description 获取全天生产数据
     * @param params 查询条件
     * @return 全天生产数据
     */
    @GetMapping("/getDayChartData")
    public Result<ProduceMonitorDayChartDto> getDayChartData(@RequestParam Map<String, Object> params) {
        if (ObjectUtils.isEmpty(params.get("matchCode"))
                || ObjectUtils.isEmpty(params.get("day"))) {
            return null;
        }
        String stationCode = null;
//        String stationCode = params.get("stationCode").toString();
        String matchCode = params.get("matchCode").toString();
        String day = params.get("day").toString();
        ProduceMonitorDayChartDto data = asphaltProduceMonitorService.getDayChartData(stationCode, matchCode, day);
        return ResultUtils.ok(data);
    }

}
